From: Carlos Garnacho Date: Tue, 22 Jul 2014 10:38:44 +0000 (+0200) Subject: keyboard: Use common code to create regular and extension key buttons X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~2307 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=69d5cef3b240d9df3b5df74df320dff8c537616b;p=gnome-shell.git keyboard: Use common code to create regular and extension key buttons The code is almost the same, so pull this out to a generic _makeKey(), and use it from both places. https://bugzilla.gnome.org/show_bug.cgi?id=733633 --- diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index 244b1d172..cfce86142 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -52,8 +52,7 @@ const Key = new Lang.Class({ _init : function(key) { this._key = key; - - this.actor = this._makeKey(); + this.actor = this._makeKey(key, GLib.markup_escape_text(key.label, -1)); this._extended_keys = this._key.get_extended_keys(); this._extended_keyboard = null; @@ -76,20 +75,19 @@ const Key = new Lang.Class({ } }, - _makeKey: function () { - let label = GLib.markup_escape_text(this._key.label, -1); + _makeKey: function (key, label) { let button = new St.Button ({ label: label, style_class: 'keyboard-key' }); button.key_width = this._key.width; button.connect('button-press-event', Lang.bind(this, function () { - this._key.press(); + key.press(); return Clutter.EVENT_PROPAGATE; })); button.connect('button-release-event', Lang.bind(this, function () { - this._key.release(); + key.release(); return Clutter.EVENT_PROPAGATE; })); @@ -112,18 +110,9 @@ const Key = new Lang.Class({ for (let i = 0; i < this._extended_keys.length; ++i) { let extended_key = this._extended_keys[i]; let label = this._getUnichar(extended_key); - let key = new St.Button({ label: label, style_class: 'keyboard-key' }); + let key = this._makeKey(extended_key, label); + key.extended_key = extended_key; - key.connect('button-press-event', Lang.bind(this, - function () { - extended_key.press(); - return Clutter.EVENT_PROPAGATE; - })); - key.connect('button-release-event', Lang.bind(this, - function () { - extended_key.release(); - return Clutter.EVENT_PROPAGATE; - })); this._extended_keyboard.add(key); } this._boxPointer.bin.add_actor(this._extended_keyboard);